package com.lukk.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lukk.pojo.Territory;
import com.lukk.service.TerritoryService;

@Controller
@RequestMapping("/territory")
public class TerritoryController {
	@Autowired
	private TerritoryService territoryService;

	public TerritoryService getTerritoryService() {
		return territoryService;
	}

	public void setTerritoryService(TerritoryService territoryService) {
		this.territoryService = territoryService;
	}

	@RequestMapping("/allProvince") // 查询所有的省份
	public @ResponseBody List<Territory> findAllProvince(Integer level) {
		return territoryService.findAllProvince(level);
	}

	@RequestMapping("/allCity") // 查询所有的区
	public @ResponseBody List<Territory> findAllTerritory(String parentId) {
		return territoryService.findAllCity(parentId);
	}

	@RequestMapping("/allCountry")
	public @ResponseBody List<Territory> findAllCountry(String code) {
		return territoryService.findAllCountry(code);
	}

	@RequestMapping("/isCovered")
	public @ResponseBody boolean isCovered(String name) {
		System.out.println("要查的区域是     " + name);
		return territoryService.isCovered(name);
	}
}
